
#ifndef OGDL_SOCKET_UNIX_H__
# define OGDL_SOCKET_UNIX_H__

# include <sys/type.h>
# include <sys/socket.h>
# include <netinet/in.h>
# include <arpa/inet.h>
# include <unistd.h>
# include <netdb.h>

# include <ogdl/network/Net.h>
# include <ogdl/network/ISocket.h>

namespace ogdl
{

    class SocketImpl : public ISocket
    {
    public:
        SocketImpl();
        SocketImpl(SocketImpl const &);
        ~SocketImpl();
        SocketImpl &operator=(SocketImpl const &);

        virtual void socket(net::SockDomain domain, net::SockType type);
        virtual void bind(std::string const &host, int port);
        virtual void listen(int backlog);

        virtual void accept(ISocket const &s); // TCP server-side only !
        virtual void connect(std::string const &host, int port); // TCP client-size only !

        virtual void close();

        virtual void read(void *buf, size_t len, int flags) = 0;
        virtual void write(void *buf, size_t len, int flags) = 0;
    private:
        int _sock;
        net::SockDomain _domain;
        net::SockType _type;

        struct sockaddr_in _sin;
        size_t _len;
    };

}

#endif  // OGDL_SOCKET_UNIX_H__